<?php

class Application_Model_BookLanguages extends Application_Model_Base{
    private static $instance = null;
    public static function getInstance(){
        if (null === self::$instance) self::$instance = new self();
        return self::$instance;
    }
    private function __clone() {}
    private function __construct() {}

    public function getPaginator(){
        //var_dump($params);
        $select = $this->getDBAdapter()->select()
            ->from('book_languages');
        $paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select);
        return new Zend_Paginator($paginatorAdapter);
    }

    public function getAll(){
        return $this->getDBAdapter()->query("
            select * from `book_languages`
        ")->fetchAll();
    }

    public function getAllForSelect(){
        $bookLanguages = $this->getDBAdapter()->query("
            select * from `book_languages`
        ")->fetchAll();
        $bookLanguagesForSelect = array();
        foreach($bookLanguages as $bookLanguage){
            $bookLanguagesForSelect[$bookLanguage['book_language_id']] = $bookLanguage['book_language_name'];
        }
        return $bookLanguagesForSelect;
    }

    public function create($data){
        $this->getDBAdapter()->insert('book_languages', $data);
    }
}